diff --git a/src/ortools/base/file.cc b/src/ortools/base/file.cc
--- a/ortools/base/file.cc
+++ b/ortools/base/file.cc
@@ -186,7 +186,7 @@
   }
 #endif  // _MSC_VER
 
-  file->Close(flags);  // Even if ReadToString() fails!
+  static_cast<void>(file->Close(flags));  // Even if ReadToString() fails!
   return absl::Status(absl::StatusCode::kInvalidArgument,
                       absl::StrCat("Could not read from '", filename, "'."));
 }